package demo.file;

import java.io.File;

public class DeleteDirs {

    public static void main(String[] args) {
        File dir = new File("d:\\sublime\\test");
        delete(dir);
    }
    //ɾ�����ļ���
    public static void delete(File dir) {
        File[] files = dir.listFiles();
        if (files.length == 0) {
            dir.delete();
            return;
        } else
            for (File file : files) {
                if (file.isDirectory())
                    delete(file);
            }
        File[] newFiles = dir.listFiles();
        if (newFiles.length == 0)
            dir.delete();
    }

}
